//
//  DesignOrderTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/6.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "DesignOrderTableViewCell.h"

@interface DesignOrderTableViewCell ()

@property (nonatomic, strong) UILabel   * nameLabel;
@property (nonatomic, strong) UILabel   * detailLabel;
@property (nonatomic, strong) UILabel   * moneyLabel;
@property (nonatomic, strong) UILabel   * statuLabel;
@property (nonatomic, strong) UILabel   * numLabel;
@property (nonatomic, strong) UILabel   * timeLabel;
@property (nonatomic, strong) UIButton  * operateBtn;

@end

@implementation DesignOrderTableViewCell

+ (DesignOrderTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"DesignOrderTableViewCell";
    DesignOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[DesignOrderTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

-(void)setDesignOrderListDataModel:(DesignOrderListDataModel *)designOrderListDataModel
{
    _designOrderListDataModel = designOrderListDataModel;
    
    self.nameLabel.text = designOrderListDataModel.demand;
    self.moneyLabel.text = [NSString stringWithFormat:@"总金额:%@元",designOrderListDataModel.total_fee];
    self.detailLabel.text = designOrderListDataModel.category;
    self.timeLabel.text = [@"订单提交时间 " stringByAppendingString:designOrderListDataModel.time];//@"2018年05月25日"
    
    if ([designOrderListDataModel.order_status isEqualToString:@"0"]) {
        self.statuLabel.text = @"已取消";
        self.numLabel.hidden = YES;
        [self.operateBtn setTitle:@"查看详情" forState:UIControlStateNormal];
    }else if ([designOrderListDataModel.order_status isEqualToString:@"1"]){
        self.statuLabel.text = @"待付款";
        self.numLabel.hidden = YES;
        [self.operateBtn setTitle:@"立即付款" forState:UIControlStateNormal];
    }else if ([designOrderListDataModel.order_status isEqualToString:@"2"]){
        self.statuLabel.text = @"竞标中";
        self.numLabel.hidden = NO;
        [self.operateBtn setTitle:@"取消订单" forState:UIControlStateNormal];
    }else if ([designOrderListDataModel.order_status isEqualToString:@"3"]){
        self.statuLabel.text = @"交易中";
        self.numLabel.hidden = YES;
        [self.operateBtn setTitle:@"交易完成" forState:UIControlStateNormal];
    }else if ([designOrderListDataModel.order_status isEqualToString:@"4"]){
        self.statuLabel.text = @"待评价";
        self.numLabel.hidden = YES;
        [self.operateBtn setTitle:@"立即评价" forState:UIControlStateNormal];
    }else if ([designOrderListDataModel.order_status isEqualToString:@"5"]){
        self.statuLabel.text = @"已完成";
        self.numLabel.hidden = YES;
        [self.operateBtn setTitle:@"查看详情" forState:UIControlStateNormal];
    }else {
        self.statuLabel.text = @"待交易";
        self.numLabel.hidden = YES;
        [self.operateBtn setTitle:@"取消订单" forState:UIControlStateNormal];
    }
}

-(void)clicked
{
    if (_btnClick) {
        _btnClick();
    }
}

- (void)createSubView {
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(40), ScreenX375(200), ScreenX375(18))];
    self.nameLabel.text = @"我需要广告设计";
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    [self addSubview:self.nameLabel];

    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(88), ScreenX375(200), ScreenX375(15))];
    self.moneyLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.moneyLabel.font = Kfont(12);
    self.moneyLabel.textAlignment = NSTextAlignmentLeft;
    self.moneyLabel.text = @"总金额:100元";
    [self addSubview:self.moneyLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(63), ScreenX375(200), ScreenX375(14))];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.detailLabel.font = Kfont(12);
    self.detailLabel.text = @"包装页面设计";
    [self addSubview:self.detailLabel];
    
    UIImageView *sLine = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(110), SCREEN_WIDTH - ScreenX375(26), 0.5)];
    sLine.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:sLine];
    
    self.statuLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(9), ScreenX375(50), ScreenX375(15))];
    self.statuLabel.text = @"交易中";
    self.statuLabel.textColor = ThemeColor;
    self.statuLabel.font = Kfont(12);
    [self addSubview:self.statuLabel];
    
    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(113), ScreenX375(44), ScreenX375(100), ScreenX375(14))];
    self.numLabel.text = @"2人竞标";
    self.numLabel.textAlignment = NSTextAlignmentRight;
    self.numLabel.textColor = ThemeColor;
    self.numLabel.font = Kfont(12);
    [self addSubview:self.numLabel];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenX375(32), SCREEN_WIDTH, 0.5)];
    line.backgroundColor = LineColor;
    [self addSubview:line];
    
    self.operateBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(107), ScreenX375(120), ScreenX375(94), ScreenX375(30))];
    self.operateBtn.backgroundColor = ThemeColor;
    self.operateBtn.layer.cornerRadius = ScreenX375(15);
    self.operateBtn.clipsToBounds = YES;
    [self.operateBtn addTarget:self action:@selector(clicked) forControlEvents:UIControlEventTouchUpInside];
    [self.operateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.operateBtn.titleLabel.font = Kfont(14);
    [self addSubview:self.operateBtn];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(193), ScreenX375(9), ScreenX375(180), ScreenX375(15))];
    self.timeLabel.text = @"订单提交时间 2018年05月25日";
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.timeLabel.font = Kfont(12);
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.timeLabel];
}

@end
